<template>
  <el-row style="text-align:left">
    <el-form :model="formData" label-width="100px">
      <el-form-item label="上级菜单">
        {{formData.parentName}}
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="formData.name"></el-input>
      </el-form-item>
      <el-form-item label="类型">
        <el-select v-model="formData.type">
          <el-option v-for="(value,key) in types" :key="value" :value="value" :label="key"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="前端路径">
        <el-input v-model="formData.url"></el-input>
      </el-form-item>
      <el-form-item label="描述">
        <el-input v-model="formData.description"></el-input>
      </el-form-item>
      <el-form-item label="排序">
        <el-input v-model="formData.sort"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleSave" type="primary">保存</el-button>
      </el-form-item>
    </el-form>
  </el-row>
</template>

<script>

export default {
  name: 'Menu',
  props: ['formData'],
  data: function() {
    return {
      types: { '菜单': 1, '按钮': 2, '隐藏': 3 }
    }
  },
  methods: {
    handleSave: function() {
        this.$api.saveMenu(this.formData).then(res =>{
                if(res.code == '000000'){
                  this.$message({
                    message: '保存成功',
                    type: 'success'
                  })
                  this.$emit('success')
                }
        })
    }
  }
}
</script>

<style>

</style>
